const reuseChatPageCheckbox = document.querySelector('#reuse-chat-page-checkbox')
const showDownloadButtonCheckbox = document.querySelector('#show-download-button-checkbox')
const filenamePrefixInput = document.querySelector('#filename-prefix-input')

chrome.storage.local.get({ reuseChatPage: true, showDownloadButton: true, filenamePrefix: 'deepseek-chat-' }, (items) => {
  reuseChatPageCheckbox.checked = items.reuseChatPage
  showDownloadButtonCheckbox.checked = items.showDownloadButton
  filenamePrefixInput.value = items.filenamePrefix
})

reuseChatPageCheckbox.onclick = function () {
  chrome.storage.local.set({ reuseChatPage: this.checked })
}
showDownloadButtonCheckbox.onclick = function () {
  chrome.storage.local.set({ showDownloadButton: this.checked })
}
filenamePrefixInput.oninput = function () {
  chrome.storage.local.set({ filenamePrefix: this.value })
}